# _*_ coding: utf-8 _*_
# @Time : 2020/10/26 15:38
# @Author : liupengfei
# @File : serializers.py

from rest_framework import serializers
from .models import Comment


class CommentSerializer(serializers.ModelSerializer):
    member = serializers.SerializerMethodField()

    def get_member(self, obj):
        return {
            'nickname': obj.member.user.nickname,
            'face_url': obj.member.face_url
        }

    class Meta:
        model = Comment
        fields = ('id', 'content', 'like_count', 'start', 'create_time', 'member')
